using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace RideMe.Core
{
    public static class Validator
    {
        /// <summary>
        /// Validates the string.
        /// </summary>
        /// <param name="value">The string to validate.</param>
        /// <returns>True if the input is a non-zero length string; otherwise, false.</returns>
        public static bool ValidString(string value)
        {
            return (value != null) && (value.Trim().Length > 0);
        }

        /// <summary>
        /// Validates the directory.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>True if the directory is valid; otherwise, false.</returns>
        public static bool ValidDirectory(string path)
        {
            return ValidString(path) & (Directory.Exists(path));
        }

        /// <summary>
        /// Validates the document.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>True if the document is valid; otherwise, false.</returns>
        public static bool ValidFile(string path)
        {
            return ValidString(path) & (File.Exists(path));
        }

        /// <summary>
        /// Adds quotes around a string (used for paths with spaces).
        /// </summary>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public static string QuoteString(string source)
        {
            return string.Format("'{0}'", source);
        }
    }
}
